﻿package mortal.game.view.forging.view
{
    import com.gengine.utils.*;
    import com.greensock.layout.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.common.*;
    import mortal.common.global.*;
    import mortal.component.gconst.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.model.player.*;
    import mortal.game.scene3D.model.player.weapon.*;
    import mortal.game.utils.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.common.pageSelect.*;
    import mortal.game.view.common.util.*;
    import mortal.game.view.forging.*;
    import mortal.game.view.forging.data.*;
    import mortal.game.view.forging.renderer.*;
    import mortal.game.view.palyer.*;
    import mortal.mvc.core.*;

    public class GemEmbedPanel extends ForgingPanelBase
    {
        private var _gemBg:GBitmap;
        private var _gemList:GTileList;
        private var _pageSelecter:PageSelecter;
        private var _putEquipImg:GImageBitmap;
        private var _equipCombatText:GImageBitmap;
        private var _equipCombat:BitmapNumberText;
        private var _reviewText:GTextFiled;
        private var _tipsDesc:GTextFiled;
        private var _switchLink:GButton;
        private var _equipNameDesc:GTextFiled;
        private var _effectPlayer:EffectPlayer;
        private var _gemPlayer:WeaponPlayer;
        private var _effectPath:String;
        private var _currShowGemData:ItemData;
        private var _currEmbedGem:GemItem;
        private var _currEmbedGemUseState:Boolean;
        private var _currExciseGemData:ItemData;
        private var _gemItemArr:Array;
        private var _gemSpr:Sprite;
        private var _currMaxGemNum:int;

        public function GemEmbedPanel(param1:Window)
        {
            this._gemItemArr = new Array();
            super(param1);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.createChildren();
            return;
        }// end function

        private function onResLoadCompl(param1 = null) : void
        {
            if (isDisposed)
            {
                return;
            }
            this.createChildren();
            return;
        }// end function

        override protected function createChildren() : void
        {
            super.createChildren();
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.EquipStrengPart, 25, 11, this));
            this.pushUIToDisposeVec(UIFactory.gBitmap(ImagesConst.TextBg3, 157 - 25, 1, this));
            var _loc_1:* = GlobalStyle.textFormatHuang2;
            _loc_1.size = 14;
            var _loc_2:* = GlobalStyle.textFormatBai;
            _loc_2.align = AlignMode.CENTER;
            this._equipNameDesc = UIFactory.gTextField("", 128, 7, 234, 20, this, _loc_2);
            this._equipNameDesc.htmlText = Language.getString(40103);
            _currOperEquip = UICompomentPool.getUICompoment(PlayerEquipItem);
            _currOperEquip.setItemStyle(ItemStyleConst.Big, "", 0, 0);
            _currOperEquip.x = 214;
            _currOperEquip.y = 73;
            this.addChild(_currOperEquip);
            this._putEquipImg = UIFactory.gImageBitmap(ImagesConst.Forging_PutInEquip, 227, 81, this);
            this.pushUIToDisposeVec(UIFactory.bg(191 - 10, 141, 139, 23, this, ImagesConst.RegionTitleBg));
            this._equipCombatText = UIFactory.gImageBitmap(ImagesConst.Forging_Text_EquipCombat, 203, 143, this);
            this._equipCombat = UIFactory.bitmapNumberText(260, 144, "FightInfoNum.png", 12, 15, -1, this);
            this._reviewText = UIFactory.gTextField(Language.getString(41133), 260, 142, 100, 20, this);
            this._switchLink = UIFactory.gButton(Language.getString(41140), 334 + 40, 167, 130, 20, this, "GreenLinkButton");
            this._switchLink.visible = false;
            this._switchLink.configEventListener(MouseEvent.CLICK, this.onClickLinkHandler);
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_GemEmbedBg, 0, 182, this));
            this._gemSpr = UIFactory.sprite(0, 197, this);
            this.addChild(this._gemSpr);
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_GemEmbedIcon, 27, 255, this));
            this.pushUIToDisposeVec(UIFactory.gImageBitmap(ImagesConst.Forging_GemExciseIcon, 365, 240, this));
            this.pushUIToDisposeVec(UIFactory.bg(107, 265, 266, 23, this, ImagesConst.RegionTitleBg));
            this._tipsDesc = UIFactory.gTextField("", 129 + 10, 266, 250, 20, this);
            this.pushUIToDisposeVec(UIFactory.bg(26, 296, 432, 125 + 14, this, ImagesConst.Forging_GemEmbedBg2));
            this._gemList = UIFactory.tileList(48, 312, 394 + 10, 94, this);
            this._gemList.columnWidth = 42 + 8;
            this._gemList.rowHeight = 42;
            this._gemList.horizontalGap = 0;
            this._gemList.verticalGap = 6;
            this._gemList.setStyle("skin", new Bitmap());
            this._gemList.setStyle("cellRenderer", GemEmbedCellRenderer);
            this._gemList.configEventListener(MouseEvent.CLICK, this.onEmbedClick);
            this.pushUIToDisposeVec(UIFactory.gTextField(Language.getString(41141), 49, 406, 106, 20, this, GlobalStyle.textFormatLv));
            var _loc_3:* = GlobalStyle.textFormatBai;
            _loc_3.align = AlignMode.CENTER;
            this._pageSelecter = UIFactory.pageSelecter(178, 404, this, PageSelecter.CompleteMode);
            this._pageSelecter.setbgStlye(ImagesConst.InputBg, _loc_3);
            this._pageSelecter.pageTextBoxSize = 50;
            this._pageSelecter.maxPage = 1;
            this._pageSelecter.configEventListener(Event.CHANGE, this.onPageChange);
            this._gemSpr.addEventListener(MouseEvent.CLICK, this.onExciseClick);
            this.initBagGemList();
            return;
        }// end function

        private function initBagGemList() : void
        {
            var _loc_1:* = Cache.instance.pack.backPackCache.getGemByType();
            _loc_1.sort(this.sortOnTypeMatch2);
            this.updateGemInfo(_loc_1);
            return;
        }// end function

        override public function updateUI() : void
        {
            super.updateUI();
            return;
        }// end function

        override public function addForgingEquip(param1:PlayerEquipItem) : void
        {
            if (param1 && param1.itemData)
            {
                super.addForgingEquip(param1);
                _currOperEquip.updateStrengLevel();
                if (this._putEquipImg.visible)
                {
                    this._putEquipImg.visible = false;
                }
                this.createGemList2(this.getMaxGemNum());
                this.updateCombat();
                this.updateGemList();
                this.updateTipsInfo();
                this.updateSwitchLink();
                this.updateEquipDesc();
                this.setGemHoleStatus(_currOperEquip.itemData.extInfo.hole_num);
                this._pageSelecter.currentPage = 1;
                this.updateGemInfoByType(_currOperEquip.itemData.itemInfo.type);
                this.clear();
                if (this._reviewText.visible)
                {
                    this._reviewText.visible = false;
                }
            }
            return;
        }// end function

        override public function updateForgingInfo() : void
        {
            this.updateCombat();
            this.addCombatChangeEffect();
            this.updateGemList();
            this.setGemHoleStatus(_currOperEquip.itemData.extInfo.hole_num);
            this.updateGemInfoByType(_currOperEquip.itemData.itemInfo.type);
            return;
        }// end function

        private function updateGemDesc() : void
        {
            var _loc_1:String = null;
            var _loc_2:int = 0;
            if (this._currShowGemData)
            {
                _loc_1 = ItemsUtil.getItemName(this._currShowGemData);
                _loc_2 = this._currShowGemData.itemInfo.itemLevel;
            }
            return;
        }// end function

        private function updateEquipDesc() : void
        {
            this._equipNameDesc.htmlText = ItemsUtil.getItemWholeName(_currOperEquip.itemData, true, 1, false);
            return;
        }// end function

        public function updateTipsInfo() : void
        {
            var _loc_1:String = null;
            var _loc_2:int = 0;
            var _loc_3:String = null;
            var _loc_4:int = 0;
            var _loc_5:String = null;
            var _loc_6:int = 0;
            if (_currOperEquip.itemData)
            {
                _loc_1 = "";
                _loc_2 = _currOperEquip.itemData.itemInfo.type;
                _loc_3 = GameDefConfig.instance.getEquipName(_loc_2);
                _loc_1 = _loc_1 + (_loc_3 + Language.getString(41142));
                _loc_4 = EquipJewelMatchConfig.instance.getJewelTypeByEquipType(_loc_2);
                _loc_5 = GameDefConfig.instance.getItem("FightRoleAttribute", _loc_4).text1;
                _loc_1 = _loc_1 + HTMLUtil.addColor(_loc_5 + Language.getString(41143), GlobalStyle.colorHuang2);
                _loc_6 = Cache.instance.pack.backPackCache.getGemByType(_loc_4).length;
                _loc_1 = _loc_1 + HTMLUtil.addColor(Language.getStringByParam(41144, _loc_6), GlobalStyle.colorLv);
                this._tipsDesc.htmlText = _loc_1;
            }
            return;
        }// end function

        private function getMaxGemNum() : int
        {
            var _loc_2:int = 0;
            var _loc_1:* = EquipmentUtil.getGemLevelHoleNum(_currOperEquip.itemData);
            if (EquipmentUtil.isCanEmbed(_currOperEquip.itemData))
            {
                _loc_2 = _loc_1 + 3;
            }
            this._currMaxGemNum = _loc_2;
            return _loc_2;
        }// end function

        private function updateGemInfoByType(param1:int = -1) : void
        {
            var _loc_2:* = Cache.instance.pack.backPackCache.getGemByType();
            if (param1 >= 0)
            {
                _loc_2.sort(this.sortOnTypeMatch);
            }
            else
            {
                _loc_2.sort(this.sortOnTypeMatch2);
            }
            this.updateGemInfo(_loc_2);
            return;
        }// end function

        private function sortOnTypeMatch(param1:ItemData, param2:ItemData) : Number
        {
            var _loc_3:int = 0;
            var _loc_4:int = 0;
            if (_currOperEquip && _currOperEquip.itemData)
            {
                _loc_3 = _currOperEquip.itemData.itemInfo.type;
                _loc_4 = EquipJewelMatchConfig.instance.getInfoByType(_loc_3).jeweltype;
            }
            if (param1.itemInfo.type == _loc_4 && param2.itemInfo.type != _loc_4)
            {
                return -1;
            }
            if (param1.itemInfo.type != _loc_4 && param2.itemInfo.type == _loc_4)
            {
                return 1;
            }
            return this.bagItemSort(param1, param2);
        }// end function

        private function sortOnTypeMatch2(param1:ItemData, param2:ItemData) : Number
        {
            var _loc_8:int = 0;
            var _loc_3:* = EquipJewelMatchConfig.instance.getEquipTypeByJewelType(param1.itemInfo.type);
            var _loc_4:* = EquipJewelMatchConfig.instance.getEquipTypeByJewelType(param2.itemInfo.type);
            var _loc_5:Array = [];
            var _loc_6:Array = [];
            var _loc_7:* = (GameController.forging.view as ForgingModule).equipDisplaySpr;
            for each (_loc_8 in _loc_3)
            {
                
                _loc_5.push(_loc_7.getEquipByType(_loc_8));
            }
            for each (_loc_8 in _loc_4)
            {
                
                _loc_6.push(_loc_7.getEquipByType(_loc_8));
            }
            if (_loc_5.length > 0 && _loc_6.length == 0)
            {
                return -1;
            }
            if (_loc_5.length == 0 && _loc_6.length > 0)
            {
                return 1;
            }
            return this.bagItemSort(param1, param2);
        }// end function

        private function bagItemSort(param1:ItemData, param2:ItemData) : int
        {
            if (param2 == null)
            {
                return -1;
            }
            if (param1 == null)
            {
                return 1;
            }
            if (ItemsUtil.isBind(param1))
            {
                if (ItemsUtil.isBind(param2))
                {
                    if (param1.serverData.itemCode > param2.serverData.itemCode)
                    {
                        return -1;
                    }
                    return 1;
                }
                else
                {
                    return -1;
                }
            }
            else
            {
                if (ItemsUtil.isBind(param2))
                {
                    return 1;
                }
                if (param1.serverData.itemCode > param2.serverData.itemCode)
                {
                    return -1;
                }
                return 1;
            }
        }// end function

        private function onClickLinkHandler(event:MouseEvent) : void
        {
            var _loc_2:Object = {};
            _loc_2["pageIndex"] = ForgingConst.Page_EquipStrengthen;
            _loc_2["equipData"] = _currOperEquip.itemData;
            Dispatcher.dispatchEvent(new DataEvent(EventName.OpenForgingPanel, _loc_2));
            return;
        }// end function

        private function onEmbedClick(event:MouseEvent) : void
        {
            var _loc_2:GemItem = null;
            var _loc_3:Array = null;
            if (event.target is GemItem)
            {
                _loc_2 = event.target as GemItem;
                if (_loc_2.itemData != null)
                {
                    this._currEmbedGem = _loc_2;
                    this._currEmbedGemUseState = _loc_2.isUseable;
                    if (this.judgeEmbed())
                    {
                        this._currEmbedGem.posInEquip = this.getEmbedPos();
                        this._currShowGemData = this._currEmbedGem.itemData;
                        _loc_3 = [_loc_2.itemData.uid];
                        Dispatcher.dispatchEvent(new DataEvent(EventName.EmbeGem, _loc_3));
                    }
                }
            }
            return;
        }// end function

        public function onEmbedSuccHandler() : void
        {
            var _loc_1:GemItem = null;
            this.updateTipsInfo();
            if (this._currEmbedGem)
            {
                for each (_loc_1 in this._gemItemArr)
                {
                    
                    if (_loc_1 && _loc_1.itemData)
                    {
                        if (this._currEmbedGem.posInEquip == _loc_1.posInEquip)
                        {
                            _loc_1.addShakeLight();
                            this.updateGemDesc();
                            return;
                        }
                    }
                }
            }
            return;
        }// end function

        private function onExciseClick(event:MouseEvent) : void
        {
            var _loc_2:GemItem = null;
            var _loc_3:Array = null;
            if (event.target is GemItem)
            {
                _loc_2 = event.target as GemItem;
                if (_loc_2.itemData != null)
                {
                    this._currExciseGemData = _loc_2.itemData;
                    _loc_3 = [_loc_2.posInEquip];
                    Dispatcher.dispatchEvent(new DataEvent(EventName.RemoveGem, _loc_3));
                }
            }
            return;
        }// end function

        public function onExciseSuccHandler() : void
        {
            if (this._currExciseGemData && this._currShowGemData)
            {
                if (this._currExciseGemData.uid == this._currShowGemData.uid)
                {
                    this._currShowGemData = null;
                    this.updateGemDesc();
                }
            }
            this.updateTipsInfo();
            return;
        }// end function

        private function judgeEmbed() : Boolean
        {
            var _loc_1:* = (GameController.forging.view as ForgingModule).equipDisplaySpr.currSelEquip;
            var _loc_2:* = this._currEmbedGem.itemData.itemInfo.type;
            var _loc_3:* = EquipJewelMatchConfig.instance.getEquipTypeByJewelType(_loc_2);
            var _loc_4:* = (GameController.forging.view as ForgingModule).equipDisplaySpr.getEquipByType(_loc_3[0]);
            if (_loc_3.length == 2)
            {
                if (!_loc_4.itemData || !EquipmentUtil.isEmbedAvailable(_loc_4.itemData))
                {
                    _loc_4 = (GameController.forging.view as ForgingModule).equipDisplaySpr.getEquipByType(_loc_3[1]);
                }
            }
            if (_loc_1 && _loc_1.itemData)
            {
                if (this._currEmbedGemUseState)
                {
                    if (_loc_3.length == 2)
                    {
                        return this.switchEquipByType(_loc_3);
                    }
                    return true;
                }
                else
                {
                    return this.switchEquip(_loc_4);
                }
            }
            else
            {
            }
            return this.switchEquip(_loc_4);
        }// end function

        private function switchEquip(param1:PlayerEquipItem) : Boolean
        {
            if (param1.itemData && !EquipmentUtil.isCanEmbed(param1.itemData))
            {
                MsgManager.showRollTipsMsg(Language.getString(41145));
                return false;
            }
            this.changeEquip(param1);
            return false;
        }// end function

        private function switchEquipByType(param1:Array) : Boolean
        {
            var _loc_2:int = 0;
            var _loc_3:PlayerEquipItem = null;
            if (!EquipmentUtil.isEmbedAvailable(_currOperEquip.itemData))
            {
                _loc_2 = _currOperEquip.itemData.itemInfo.type == param1[0] ? (param1[1]) : (param1[0]);
                _loc_3 = (GameController.forging.view as ForgingModule).equipDisplaySpr.getEquipByType(_loc_2);
                if (_loc_3.itemData && EquipmentUtil.isCanEmbed(_loc_3.itemData) && EquipmentUtil.isEmbedAvailable(_loc_3.itemData))
                {
                    this.changeEquip(_loc_3);
                    return false;
                }
            }
            return true;
        }// end function

        private function getEmbedPos() : int
        {
            var _loc_1:ItemExInfo = null;
            var _loc_2:int = 0;
            if (_currOperEquip.itemData)
            {
                _loc_1 = _currOperEquip.itemData.extInfo;
                _loc_2 = 1;
                while (_loc_2 <= 8)
                {
                    
                    if (_loc_1["h" + _loc_2] == "0")
                    {
                        return _loc_2;
                    }
                    _loc_2++;
                }
            }
            return 0;
        }// end function

        private function changeEquip(param1:PlayerEquipItem) : void
        {
            if (param1.itemData)
            {
                (GameController.forging.view as ForgingModule).equipDisplaySpr.currSelEquip = param1;
                param1.setSelEffect(true);
                Dispatcher.dispatchEvent(new DataEvent(EventName.AddForgingEquip, param1));
            }
            else
            {
                MsgManager.showRollTipsMsg(Language.getString(41146));
            }
            return;
        }// end function

        private function onPageChange(event:Event) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GemPage));
            return;
        }// end function

        public function updateGemInfo(param1:Array) : void
        {
            var _loc_8:Object = null;
            var _loc_9:int = 0;
            var _loc_10:ItemData = null;
            var _loc_11:int = 0;
            var _loc_2:* = new DataProvider();
            var _loc_3:* = Math.ceil(param1.length / ForgingConst.PageSize);
            this.updatePageInfo(_loc_3);
            var _loc_4:* = (this._pageSelecter.currentPage - 1) * ForgingConst.PageSize;
            var _loc_5:* = this._pageSelecter.currentPage * ForgingConst.PageSize;
            var _loc_6:* = param1.slice(_loc_4, _loc_5);
            var _loc_7:* = (GameController.forging.view as ForgingModule).equipDisplaySpr.currSelEquip;
            if (_loc_7 && _loc_7.itemData)
            {
                _loc_9 = EquipJewelMatchConfig.instance.getInfoByType(_loc_7.itemData.itemInfo.type).jeweltype;
            }
            for each (_loc_10 in _loc_6)
            {
                
                _loc_8 = new Object();
                _loc_8.gemData = _loc_10;
                _loc_8.gemType = _loc_9;
                _loc_2.addItem(_loc_8);
            }
            if (_loc_6.length < ForgingConst.PageSize)
            {
                _loc_11 = 0;
                while (_loc_11 < ForgingConst.PageSize - _loc_6.length)
                {
                    
                    _loc_8 = new Object();
                    _loc_2.addItem(_loc_8);
                    _loc_11++;
                }
            }
            this._gemList.dataProvider = _loc_2;
            this._gemList.drawNow();
            return;
        }// end function

        public function updateGemList() : void
        {
            var _loc_2:String = null;
            var _loc_3:ItemData = null;
            var _loc_5:int = 0;
            var _loc_1:* = new Array();
            var _loc_4:int = 1;
            while (_loc_4 <= this._currMaxGemNum)
            {
                
                _loc_2 = _currOperEquip.itemData.extInfo["h" + _loc_4];
                if (_loc_2 && _loc_2 != "0")
                {
                    _loc_5 = _loc_2.split("#")[0];
                    _loc_3 = new ItemData(_loc_5);
                }
                else
                {
                    _loc_3 = null;
                }
                _loc_1.push(_loc_3);
                _loc_4++;
            }
            _loc_4 = 0;
            while (_loc_4 < _loc_1.length)
            {
                
                if (_loc_1[_loc_4] != null)
                {
                    (this._gemItemArr[_loc_4] as GemItem).itemData = _loc_1[_loc_4];
                    (this._gemItemArr[_loc_4] as GemItem).isShowLevel = true;
                    (this._gemItemArr[_loc_4] as GemItem).posInEquip = _loc_4 + 1;
                }
                else
                {
                    this._gemItemArr[_loc_4].clear();
                }
                _loc_4++;
            }
            return;
        }// end function

        private function updateSwitchLink() : void
        {
            var _loc_1:* = _currOperEquip.itemData.extInfo.hole_num;
            var _loc_2:* = this.getMaxGemNum();
            if (_loc_1 < _loc_2)
            {
                this._switchLink.visible = true;
            }
            else
            {
                this._switchLink.visible = false;
            }
            return;
        }// end function

        private function updatePageInfo(param1:int) : void
        {
            this._pageSelecter.maxPage = param1;
            return;
        }// end function

        private function updateCombat() : void
        {
            this._equipCombat.text = "" + _currOperEquip.itemData.extInfo.combat;
            return;
        }// end function

        private function addCombatChangeEffect() : void
        {
            var _loc_1:Array = [FilterConst.colorGlowFilter(GlobalStyle.colorHuang2Uint)];
            EffectManager.glowFilterUnReg(this._equipCombat);
            EffectManager.glowFilterReg(this._equipCombat, _loc_1, 1, 10, 0, 3);
            return;
        }// end function

        private function createGemList(param1:int) : void
        {
            var _loc_12:GemItem = null;
            var _loc_2:int = 288;
            var _loc_3:int = 288;
            var _loc_4:int = 48;
            var _loc_5:int = 48;
            var _loc_6:* = (_loc_2 - _loc_4) / 2;
            var _loc_7:* = (_loc_3 - _loc_5) / 2;
            var _loc_8:* = _loc_2 - _loc_4;
            var _loc_9:* = _loc_3 - _loc_5;
            var _loc_10:Array = [];
            switch(param1)
            {
                case 3:
                {
                    _loc_10 = [{x:_loc_6, y:0}, {x:_loc_8, y:_loc_7}, {x:0, y:_loc_7}];
                    break;
                }
                case 4:
                {
                    _loc_10 = [{x:_loc_6, y:0}, {x:_loc_8, y:_loc_7}, {x:_loc_6, y:_loc_9}, {x:0, y:_loc_7}];
                    break;
                }
                case 5:
                {
                    _loc_10 = [{x:_loc_6, y:0}, {x:_loc_8, y:86}, {x:196, y:220}, {x:41, y:220}, {x:0, y:86}];
                    break;
                }
                case 6:
                {
                    _loc_10 = [{x:_loc_6, y:0}, {x:_loc_8, y:62}, {x:_loc_8, y:188}, {x:_loc_6, y:_loc_9}, {x:0, y:188}, {x:0, y:62}];
                    break;
                }
                case 7:
                {
                    _loc_10 = [{x:_loc_6, y:0}, {x:216, y:42}, {x:_loc_8, y:142}, {x:184, y:233}, {x:54, y:233}, {x:0, y:142}, {x:24, y:42}];
                    break;
                }
                case 8:
                {
                    _loc_10 = [{x:_loc_6, y:0}, {x:210, y:31}, {x:_loc_8, y:_loc_7}, {x:210, y:212}, {x:_loc_6, y:_loc_9}, {x:27, y:212}, {x:0, y:_loc_7}, {x:27, y:31}];
                    break;
                }
                default:
                {
                    break;
                }
            }
            DisplayUtil.removeAllChild(this._gemSpr);
            this._gemItemArr.length = 0;
            var _loc_11:int = 0;
            while (_loc_11 < _loc_10.length)
            {
                
                _loc_12 = UICompomentPool.getUICompoment(GemItem);
                this._gemItemArr.push(_loc_12);
                _loc_12.x = _loc_10[_loc_11].x;
                _loc_12.y = _loc_10[_loc_11].y;
                _loc_12.setItemStyle(ItemStyleConst.Small, ImagesConst.EquipItemBg, 5, 5);
                this._gemSpr.addChild(_loc_12);
                _loc_11++;
            }
            return;
        }// end function

        private function createGemList2(param1:int) : void
        {
            var _loc_5:GemItem = null;
            var _loc_2:* = 65 * param1 - 17;
            var _loc_3:int = 494;
            this._gemSpr.x = (_loc_3 - _loc_2) / 2;
            DisplayUtil.removeAllChild(this._gemSpr);
            this._gemItemArr.length = 0;
            var _loc_4:int = 0;
            while (_loc_4 < param1)
            {
                
                _loc_5 = UICompomentPool.getUICompoment(GemItem);
                this._gemItemArr.push(_loc_5);
                _loc_5.x = 65 * _loc_4;
                _loc_5.y = 0;
                _loc_5.setItemStyle(ItemStyleConst.Small, ImagesConst.EquipItemBg, 5, 5);
                this._gemSpr.addChild(_loc_5);
                _loc_4++;
            }
            return;
        }// end function

        private function setGemHoleStatus(param1:int) : void
        {
            var _loc_5:int = 0;
            var _loc_6:String = null;
            var _loc_2:int = 0;
            while (_loc_2 < this._gemItemArr.length)
            {
                
                if (_loc_2 < param1)
                {
                    if (this._gemItemArr[_loc_2].itemData == null)
                    {
                        this._gemItemArr[_loc_2].isOpened = true;
                    }
                }
                else
                {
                    this._gemItemArr[_loc_2].isOpened = false;
                }
                _loc_2++;
            }
            var _loc_3:int = 3;
            var _loc_4:* = this._gemItemArr.length - 1;
            while (_loc_4 >= param1)
            {
                
                _loc_5 = _loc_3 > 0 ? (_loc_3 * 3) : (3);
                _loc_6 = Language.getStringByParam(21486, HTMLUtil.addColor(Language.getString(21487) + _loc_5, GlobalStyle.colorLv));
                (this._gemItemArr[_loc_4] as GemItem).toolTipData = _loc_6;
                _loc_3 = _loc_3 - 1;
                _loc_4 = _loc_4 - 1;
            }
            return;
        }// end function

        public function clear() : void
        {
            this._currEmbedGem = null;
            this._currExciseGemData = null;
            this._currShowGemData = null;
            return;
        }// end function

        override public function clearUI() : void
        {
            var _loc_1:GemItem = null;
            super.clearUI();
            this._putEquipImg.visible = true;
            this._equipCombat.text = "";
            this._tipsDesc.text = "";
            this._equipNameDesc.text = "";
            this._reviewText.visible = true;
            this.clear();
            for each (_loc_1 in this._gemItemArr)
            {
                
                _loc_1.itemData = null;
            }
            DisplayUtil.removeAllChild(this._gemSpr);
            return;
        }// end function

        public function get pageSelecter() : PageSelecter
        {
            return this._pageSelecter;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            var _loc_2:GemItem = null;
            super.disposeImpl(param1);
            if (_isCreateChildren)
            {
                _isCreateChildren = false;
                for each (_loc_2 in this._gemItemArr)
                {
                    
                    _loc_2.dispose(param1);
                    _loc_2 = null;
                }
                this._gemList.dispose(param1);
                this._pageSelecter.dispose(param1);
                _currOperEquip.dispose(param1);
                this._putEquipImg.dispose(param1);
                this._equipCombatText.dispose(param1);
                this._equipCombat.dispose(param1);
                this._reviewText.dispose(param1);
                this._tipsDesc.dispose(param1);
                this._switchLink.dispose(param1);
                this._equipNameDesc.dispose(param1);
                this._gemSpr.removeEventListener(MouseEvent.CLICK, this.onExciseClick);
                UICompomentPool.disposeObject(this._gemSpr, Sprite);
                this._gemList = null;
                this._pageSelecter = null;
                this._currShowGemData = null;
                this._currEmbedGem = null;
                this._currExciseGemData = null;
                _currOperEquip = null;
                this._putEquipImg = null;
                this._equipCombatText = null;
                this._equipCombat = null;
                this._gemItemArr.length = 0;
                this._currMaxGemNum = 0;
                this._gemSpr = null;
                this._reviewText = null;
                this._tipsDesc = null;
                this._switchLink = null;
                this._equipNameDesc = null;
            }
            return;
        }// end function

    }
}
